package com.example.demo.model;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 自定义资源文件test.properties  使用如下三个注解读取  prefix为自定义参数的前缀，一个资源文件可供多个配置类使用，通过prefix区分
 */
@Component
@ConfigurationProperties(prefix="person")
@PropertySource("classpath:test.properties")
public class TestProperties1 {
    private String name;
    private String idcard;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    @Override
    public String toString() {
        return "TestProperties1{" +
                "name='" + name + '\'' +
                ", idcard='" + idcard + '\'' +
                '}';
    }
}
